{extend name="base" /} {block name="css"}
<link rel="stylesheet" href="__ADMIN__/css/form.css"> {/block} {block name="body"}
<div class="admin-main layui-form">
    <div class="layui-field-box">
        <div class="layui-box-searchber" style="overflow: visible">
            <button class="layui-btn layui-btn-sm" data-url="{:url('admin/artcomment/alldelete')}" lay-submit lay-filter="alldelete">删除选中</button>
       
            <form class="layui-form layui-form-pane" action="{:url('admin/artcomment/index')}" method="get">
                <div class="layui-inline">
                    <label class="layui-form-label">关键字</label>
                    <div class="layui-input-inline">
                        <input type="text" name="keyword" value="{$keyword}" placeholder="请输入关键字" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline" style="width:100px">
                    
                    <select name="open" lay-filter="selectopen">
                            <option value="all"  {if condition="$open eq 'all'"}selected="selected"{/if}>全部</option>
                            <option value="0" {if condition="$open eq 0"}selected="selected"{/if}>隐藏</option>
                            <option value="1" {if condition="$open eq 1"}selected="selected"{/if}>显示</option>
                     </select>
                   
                </div>
                <div class="layui-inline">
                    <button class="layui-btn  layui-btn-sm">搜索</button>
                </div>
            </form>
        </div>
        <hr>
        <hr>
        <table class="layui-table admin-table">
            <thead>
                <tr>
                    <th width="5%" align="center"><input type="checkbox"  lay-skin="primary" name="checkAll" lay-filter="checkAll"></th>
                    <th width="5%" align="center">ID</th>
                    <th width="30%" align="center">评论内容</th>
                    <th width="30%" align="center">所属文章</th>
                    <th width="10%" align="center">用户</th>
                    <th width="10%" align="center">评论时间</th>
                    <th width="10%" align="center">状态</th>
                    <th width="10%" align="center">基本操作</th>
                </tr>
            </thead>
            <tbody id="content">
                {volist name="tptc" id="vo"}
                <tr>
                    <td align="center"><input type="checkbox" lay-skin="primary" name="ids[{$vo.id}]" lay-filter="checkOne" value="{$vo.id}"></td>
                    <td align="center">{$vo.id}</td>
                    <td style="padding-left: 20px;">
                        <a target="_blank" href="{:routerurl('index/index/html',array('id'=>$vo.fid))}">
                            <?php echo mb_substr(strip_tags($vo['content']), 0, 35, 'utf-8');?>...</a>
                    </td>
                    <td style="padding-left: 20px;"><a target="_blank" href="{:routerurl('index/index/html',array('id'=>$vo.fid))}">{$vo.title}</a></td>
                    <td align="center"><a target="_blank" href="{:url('user/index/home',array('id'=>$vo.uid))}">{$vo.username}</a></td>
                    <td align="center">{$vo.time|friendlyDate}</td>
                    <td align="center">
                        <input type="checkbox" lay-skin="switch" lay-text="显示|隐藏" lay-filter="switchstatus" value="{$vo['id']}" {php}echo $vo[ 'status']==1 ? 'checked' : '';{/php}>
                    </td>
                    <td align="center">
                        <a class="elementdel layui-btn layui-btn-danger layui-btn-sm" href="javascript:;" data-id="{$vo.id}" data-url="{:url('admin/artcomment/delete',array('id'=>$vo['id']))}" title="删除">删除</a>

                    </td>
                </tr>
                {/volist}
            </tbody>
        </table>
    </div>


</div>
{/block} {block name="page"}
<div class="btable-paged">
    <div class="layui-main">
        {$tptc->render()}
    </div>
</div>
{/block} {block name="js"}
<script type="text/javascript" src="__ADMIN__/js/delelement.js"></script>
<script>
    layui.use(['form'], function() {
        var form = layui.form;
        var jq=layui.jquery;
form.on('switch(switchstatus)', function(data) {
    loading = layer.load(2, {
        shade: [0.2, '#000']
    });
    if (data.elem.checked) {
        status = 1;
    } else {
        status = 0;
    }
    var url = "{:url('admin/artcomment/toggle')}?id=" + data.value + '&status=' + status + '&name=status';


    jq.get(url, function(data) {

        if (data.code == 200) {
            layer.close(loading);
            layer.msg(data.msg, {
                icon: 1,
                time: 1000
            });
        } else {
            layer.close(loading);
            layer.msg(data.msg, {
                icon: 2,
                anim: 6,
                time: 1000
            });
        }
    });
    return false;
 });
});
</script>

{/block}